Skip to content

Close check_delimiters.py gap: catch parens split across echo lines - #409

Merged
mixmansoundude merged 1 commit into
mainfrom
claude/bootstrapper-execution-branches-ox2izi
Aug 1, 2026
Merged

Close check_delimiters.py gap: catch parens split across echo lines#409
mixmansoundude merged 1 commit into
mainfrom
claude/bootstrapper-execution-branches-ox2izi

Conversation

@mixmansoundude

Copy link
Copy Markdown
Owner

Summary

Follow-up to PR #408, which shipped a real batch-syntax regression: a ( opened on one echo line and its matching ) closed on the next echo line, both inside a parenthesized if block. cmd.exe's block parser counts parens in echo text too, so the stray closing paren prematurely ended the block and broke 6 CI lanes simultaneously (failed was unexpected at this time.) -- caught only by real CI, not by any local check, because check_delimiters.py's paren-balance logic is a whole-file LIFO scan: a stray (...) pair inside echo text is individually balanced, so it never trips the existing unclosed/mismatched detection.

This PR closes that gap:

  • tools/check_delimiters.py now tracks, for .bat/.cmd files, whether a ( was opened on an echo line while already nested inside another open bracket (a real enclosing if/for block). If its matching ) closes on a different source line, it's flagged.
  • Scoped to "already nested" specifically: a top-level echo statement with no enclosing block has no block-closing search for cmd.exe to corrupt, so flagging it would be a false positive. A real, harmless instance of exactly this shape already exists in run_setup.bat (:print_fastpath_ambiguous_note) and is used as the negative test case.
  • docs/agent-lessons-learned.md's existing entry on this hazard (added in PR fix: backlog items 8, 14, 19 -- UNC WARN, misleading syntax error, cache-lane trap #408) is updated to say the gap is now closed, instead of describing it as an open limitation.

Test plan

  • python tools/check_delimiters.py run_setup.bat -- clean (no false positives on the real file)
  • python tools/check_delimiters.py run (full repo sweep, all supported file types) -- clean
  • New unit tests in tests/test_check_delimiters_import.py: flags a paren split across echo lines inside a real if block; does NOT flag the same textual pattern at top level (no enclosing block); does NOT flag a balanced same-line pair
  • Reconstructed the exact broken PR fix: backlog items 8, 14, 19 -- UNC WARN, misleading syntax error, cache-lane trap #408 snippet as a scratch .bat file and confirmed the new check catches it
  • Full sanity sweep (tools/run_sanity_sweep.sh): compileall, pyflakes, delimiter check, markdownlint, yamllint, actionlint, ASCII sweep, PowerShell AST parse sweep, pytest (461 passed, 2 skipped) -- all clean

🤖 Generated with Claude Code


Generated by Claude Code

Today's regression (unbalanced parens across two echo lines inside an
if-block, PR #408 commit fd52a3f) passed check_delimiters.py clean
because a stray (...) pair inside echo text is individually balanced
from a whole-file LIFO paren-count perspective -- the hazard is
specifically about a cross-line split landing inside an already-open
enclosing block, not a raw count mismatch.

check_delimiters.py now tracks, for .bat/.cmd files, whether a '('
opened on an echo line while already nested inside another open
bracket, and flags it if the matching ')' closes on a different line.
Scoped to "already nested" so a harmless top-level echo statement with
no enclosing block (a real instance exists in run_setup.bat,
:print_fastpath_ambiguous_note) doesn't false-positive.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A4iE1BRSkUETwz237XeuTW
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d3d8fff7-5ecb-4f4e-a333-2d3c41ecfee8

📥 Commits

Reviewing files that changed from the base of the PR and between 8ea3b9d and 4b6367b.

📒 Files selected for processing (3)
  • docs/agent-lessons-learned.md
  • tests/test_check_delimiters_import.py
  • tools/check_delimiters.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved batch-file delimiter checking to detect parenthesis pairs split across lines within nested command blocks, including echo text.
    • Reduced false positives by correctly allowing split pairs at the top level and balanced pairs on a single line.
    • Added clearer diagnostic reporting for affected nested-block cases.
  • Documentation

    • Updated guidance with examples explaining when split parentheses are flagged or considered safe.

Walkthrough

check_delimiters.py now detects parentheses split across nested batch echo lines without flagging equivalent top-level or same-line cases. Regression tests cover all three patterns, and the lesson document records the rule.

Changes

Nested echo delimiter detection

Layer / File(s) Summary
Track nested echo parentheses
tools/check_delimiters.py
The checker classifies echo commands, stores echo-origin metadata for opening parentheses, and reports delayed closures inside nested blocks.
Validate behavior and document rules
tests/test_check_delimiters_import.py, docs/agent-lessons-learned.md
Tests cover nested-block errors, top-level split pairs, and same-line balanced pairs. Documentation describes the updated behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BatchFile
  participant DelimiterChecker
  participant DelimiterStack
  participant IssueReporter

  BatchFile->>DelimiterChecker: provide echo and delimiter lines
  DelimiterChecker->>DelimiterStack: push nested echo parenthesis metadata
  DelimiterChecker->>DelimiterStack: pop later closing parenthesis
  DelimiterChecker->>IssueReporter: report delayed nested echo closure
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/bootstrapper-execution-branches-ox2izi

Comment @coderabbitai help to get the list of available commands.

@mixmansoundude
mixmansoundude enabled auto-merge (squash) August 1, 2026 04:51
@mixmansoundude
mixmansoundude merged commit 40e6187 into main Aug 1, 2026
10 of 11 checks passed
@mixmansoundude
mixmansoundude deleted the claude/bootstrapper-execution-branches-ox2izi branch August 1, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants